<template>
  <div>
    <Table size="large" border :columns="dataTitle" :data="data"></Table>
  </div>
</template>

<script>
  export default {
    props:['nameSelect'],
    data () {
      return {
        tag: {
          'title': '客户通过率',
          'path': '/work/passRate/list'
        },
          dataTitle:[
          {
            title: '类型',
            key: 'type',
            align:'center',
            render: (h, params) => {
              return h('strong', params.row.type);
            }
          },
          {
            title: '申请数',
            key: 'apply',
            align:'center'
          },
          {
            title: '审核通过数',
            key: 'passNum',
            align:'center'
          },
          {
            title: '审核通过率(%)',
            key: 'passRate',
            align:'center',
            render: (h,params) =>{
              return h('div',(params.row.passRate*100).toFixed(2))
            }

          },
           {
            title: '放款数',
            key: 'loanNum',
            align:'center'

          },
           {
            title: '放款率(%)',
            key: 'loanRate',
            align:'center',
            render: (h,params) =>{
              return h('div',(params.row.loanRate*100).toFixed(2))
            }
          },
          {
            title: '放款金额(元)',
            key: 'loanMoney',
            align:'center',
            render: (h,params) =>{
              return h('div',(params.row.loanMoney/100).toFixed(2))
            }
          }
        ],
        data:[],
      }
    },
    mounted(){
      this.getData();
      this.tag.name = this.nameSelect;
        console.log(this.tag,'通过');
      this.$store.commit('changeTag', this.tag.path);
      this.$store.commit('openPage', this.tag);
    },
    methods: {
     getData(){
       this.$post('/statistics/customer/throughRate').then(res => {
         console.log(res,'kehu1');
         let data = res.data;
           this.data = [
                {
                  type:'总的',
                  apply : data.orderApplyCount,
                  passNum : data.orderAuditThoughCount,
                  passRate :data.orderAuditThoughRate ,
                  loanNum:data.orderLoanCount,
                  loanRate:data.orderLoanRate,
                  loanMoney:data.orderLoanCount,

                },
                {
                  type:'新户',
                  apply :data.newUserOrderApplyCount ,
                  passNum :data.newUserOrderAuditThoughCount,
                  passRate : data.newUserOrderAuditThoughRate,
                  loanNum:data.newUserOrderLoanCount,
                  loanRate:data.newUserOrderLoanRate,
                  loanMoney:data.newUserOrderApplyCount,
                },
                 {
                  type:'次新户',
                  apply :data.minorNewUserOrderApplyCount ,
                  passNum :data.minorNewUserOrderAuditThoughCount,
                  passRate : data.minorNewUserOrderAuditThoughRate,
                  loanNum:data.minorNewUserOrderLoanCount,
                  loanRate:data.minorNewUserOrderLoanRate,
                  loanMoney:data.minorNewUserOrderLoanAmount,
                },
                 {
                  type:'老户',
                  apply :data.oldUserOrderApplyCount ,
                  passNum :data.oldUserOrderAuditThoughCount,
                  passRate : data.oldUserOrderAuditThoughRate,
                  loanNum:data.oldUserOrderLoanCount,
                  loanRate:data.oldUserOrderLoanRate,
                  loanMoney:data.oldUserOrderLoanAmount,
                }
              ]
       })
     }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .list-btn{
    margin-bottom: 5px;
    margin-right: 5px;
    display: inline-block;
  }
  .refresh-btn{
    float: right;
  }

</style>
